package com.jiuling.qiniu.oss.config;

import com.jiuling.qiniu.config.QiNiuConfig;
import com.jiuling.qiniu.oss.enums.RegionEnum;
import com.qiniu.storage.Region;

/**
 * 七牛云对象存储配置
 * @author 紫灵
 * @date 2023年05月23日 10时24分01秒
 */
public class QiNiuOssConfig {

    /** 七牛云配置 */
    private QiNiuConfig qiNiuConfig;
    /** 储存桶 */
    private String bucket;
    /** 区域 */
    private RegionEnum region;
    /** 外链 */
    private String externalLink;

    public QiNiuConfig getQiNiuConfig() {
        return qiNiuConfig;
    }

    public void setQiNiuConfig(QiNiuConfig qiNiuConfig) {
        this.qiNiuConfig = qiNiuConfig;
    }

    public String getBucket() {
        return bucket;
    }

    public void setBucket(String bucket) {
        this.bucket = bucket;
    }

    public Region getRegion() {
        return region.getRegions()[0];
    }

    public void setRegion(RegionEnum region) {
        this.region = region;
    }

    public String getExternalLink() {
        return externalLink;
    }

    public void setExternalLink(String externalLink) {
        this.externalLink = externalLink;
    }

    public static Builder builder(){
        return new Builder();
    }

    public static class Builder{
        private final QiNiuOssConfig qiNiuOssConfig;

        public Builder() {
            this.qiNiuOssConfig = new QiNiuOssConfig();
        }

        public Builder addQiNiuConfig(QiNiuConfig qiNiuConfig){
            this.qiNiuOssConfig.qiNiuConfig = qiNiuConfig;
            return this;
        }

        public Builder addBucket(String bucket){
            this.qiNiuOssConfig.bucket = bucket;
            return this;
        }

        public Builder addRegion(RegionEnum region){
            this.qiNiuOssConfig.region = region;
            return this;
        }

        public Builder addExternalLink(String externalLink){
            this.qiNiuOssConfig.externalLink = externalLink;
            return this;
        }

        public QiNiuOssConfig build(){
            return this.qiNiuOssConfig;
        }
    }
}
